package com.dhsc.service.impl.csgl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dhsc.domain.ywzx.csgl.YwqqglVo;
import com.dhsc.domain.yypt.LayuiTableVo;
import com.dhsc.domain.yypt.ResponseObject;
import com.dhsc.exception.MyException;
import com.dhsc.local.dao.csgl.IYwqqglDao;
import com.dhsc.service.csgl.IYwqqglService;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;

import lombok.extern.slf4j.Slf4j;

/**
 * @ClassName: YwqqglServiceImpl
 * @Description: 业务请求管理
 * @date: 2023/9/11 14:56
 * @author: gx
 */
@Service
@Slf4j
public class YwqqglServiceImpl implements IYwqqglService {

    @Autowired
    private IYwqqglDao ywqqglDao;


    @Override
    public LayuiTableVo queryYwqqgl(YwqqglVo ywqqglVo) {
        LayuiTableVo obj = new LayuiTableVo();
        try {
            PageMethod.startPage(ywqqglVo.getPage(), ywqqglVo.getLimit());
            List<YwqqglVo> list = ywqqglDao.queryYwqqgl(ywqqglVo);
            PageInfo<YwqqglVo> pageInfo = new PageInfo<>(list);
            obj.setData(list);
            obj.setMsg("");
            obj.setCount(pageInfo.getTotal());
            obj.setCode(0);
        }catch (Exception e){
            log.error("查询业务请求管理信息出错",e);
            throw new MyException("查询业务请求管理信息出错",e);
        }
        return obj;
    }

    @Override
    public ResponseObject saveYwqqgl(YwqqglVo ywqqglVo) {
        ResponseObject obj = new ResponseObject();
        try {
            ywqqglDao.updateYwqqgl(ywqqglVo);
            obj.setStatus(200);
        }catch (Exception e){
            log.error("保存业务请求管理信息出错",e);
            throw new MyException("保存业务请求管理信息出错",e);
        }
        return obj;
    }

    @Override
    public ResponseObject queryTxtdm(YwqqglVo ywqqglVo) {
        ResponseObject obj = new ResponseObject();
        try {
            List<YwqqglVo> ywqqglVos = ywqqglDao.queryTxtdm(ywqqglVo);
            obj.setData(ywqqglVos);
            obj.setStatus(200);
        }catch (Exception e){
            log.error("查询字典信息出错",e);
            throw new MyException("查询字典信息出错",e);
        }
        return obj;
    }
}
